<?php /* Smarty version 2.6.20, created on 2016-07-26 14:08:16
         compiled from product_opear.htm */ ?>
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/script/jquery.ui.js"></script>
<script type="text/javascript" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/script/Validator.js"></script>
<div class="container">
<div class="oflow" style="height:230px">
<input name="skuId" type="hidden" id="skuId" value="<?php echo $this->_tpl_vars['skuInfo']['id']; ?>
">
<input name="type" type="hidden" id="type" value="<?php echo $this->_tpl_vars['skuInfo']['type']; ?>
">
<input name="act" type="hidden" id="act" value="product_opear">
<table class="table">
    <thead>
        <tr>
            <th class="partition" colspan="99">商品设置</th>
        </tr>
    </thead>
    <tbody>
    <tr>
        <td width="100"><?php if ($this->_tpl_vars['skuInfo']['type'] == 1): ?>现货<?php elseif ($this->_tpl_vars['skuInfo']['type'] == 2): ?>保税<?php else: ?>直邮<?php endif; ?>供应商</td>
        <td>
        	<input type="radio" name="ms_supplier" value="-1" <?php if ($this->_tpl_vars['skuInfo']['supplierId'] == -1): ?>checked<?php endif; ?> />不支持<br />
        	<input type="radio" name="ms_supplier" value="0" <?php if ($this->_tpl_vars['skuInfo']['supplierId'] == 0): ?>checked<?php endif; ?> />自营<br />
        	<?php if ($this->_tpl_vars['skuInfo']['type'] != 3): ?>
        	<input type="radio" name="ms_supplier" value="1" <?php if ($this->_tpl_vars['skuInfo']['supplierId'] > 0): ?>checked<?php endif; ?> />其他<br />
            <select name="supplierId" id="supplierId" style="display:<?php if ($this->_tpl_vars['skuInfo']['supplierId'] > 0): ?>block<?php else: ?>none<?php endif; ?>;">
            	<?php $_from = $this->_tpl_vars['suppliers']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['supplier']):
?>
            	<option value="<?php echo $this->_tpl_vars['supplier']['supplieid']; ?>
" <?php if ($this->_tpl_vars['supplier']['supplieid'] == $this->_tpl_vars['skuInfo']['supplierId']): ?>selected<?php endif; ?> ><?php echo $this->_tpl_vars['supplier']['title']; ?>
(库存：<?php echo $this->_tpl_vars['supplier']['stock']; ?>
)</option>
            	<?php endforeach; else: ?>
            	<option value="">暂无供应商</option>
            	<?php endif; unset($_from); ?>
            </select>
            <?php endif; ?>
        </td>
    </tr>
    </tbody>
</table>
<div class="dialog_button">
    <input id="save" type="button" value="保存">
</div>
<div id="error"></div> 
<script>
$(function(){
	$("input[name='ms_supplier']").bind('change',function(){
		var ms_supplier = $("input[name='ms_supplier']:checked").val();
		if(ms_supplier==1){
			$('#supplierId').show();
		}else{
			$('#supplierId').hide();
		}
	});
});
$("#save").click(function () {
	var skuId = $('#skuId').val();
	var act = $('#act').val();
	var type = $('#type').val();
	var ms_supplier = $("input[name='ms_supplier']:checked").val();
	var supplierId = $('#supplierId').val();
	if(ms_supplier!=1){
		supplierId = ms_supplier;
	}else{
		if(!(supplierId>0)){
			alert('供应商为空，如果无供应商，请选择不支持或自营！');
			return false;
		}
	}
	$.post('<?php echo $this->_tpl_vars['config']['weburl']; ?>
/admin/module.php?m=micro_shop&s=products_list.php',{"id":skuId,"act":act,"type":type,"supplierId":supplierId},function(res){
		if(res.code!=0){
			alert(res.msg);
		}else{
		    window.parent.main.document.location.reload();
		    window.parent.DialogManager.close("product_opear");
		}
	},'json');
    return false;
});
</script>
</div>
</div>